<template>
    <div>
      <!-- <button></button> -->
       <el-button type="primary" :disabled="aaa" @click="throttledClick" >点击我（节流处理）</el-button>
      <p>点击次数: {{ clickCount }}</p>
    </div>
  </template>
  
  <script setup>
  import { ref, onUnmounted } from 'vue';
  
  let aaa = ref(false); // 初始化aaa为false
  let clickCount = ref(0);
  const wait = 5000; // 节流时间间隔
  
  // 节流函数（与之前相同）
  const throttle = (func, delay) => {
    let lastRun = 0;
     let throttle =function (...args) {    
      const now = new Date().getTime();
      if (now - lastRun >= delay) {
        lastRun = now;
        func.apply(this, args);
      }
      aaa.value = true;
    };
    

    return throttle
  };
  
  // 需要被节流的函数（与之前相同）
  const handleClick = () => {
    clickCount.value++;
    console.log(`按钮被点击了 ${clickCount.value} 次`);
  };
  
  // 创建节流后的函数（与之前相同）
  const throttledClick = throttle(handleClick, wait);
  

  

  </script>
  
  <style scoped>
  /* 添加一些简单的样式 */
  button {
    padding: 10px 20px;
    font-size: 16px;
  }
  </style>